import {IOriginNormalVertexData, IOriginVertexData} from "./originDtata";


export function calNormalVertices(data:IOriginVertexData,d = 0.1) :IOriginNormalVertexData{
    let positions = data.positions;
    let normals = data.normals;
    let size = positions.length / 3;

    // 不需要索引
    let posArr = new Array(positions.length * 2);
    for (let i = 0; i < size; ++i){
        let x = positions[3 * i];
        let y = positions[3 * i + 1];
        let z = positions[3 * i + 2];
        let nx = normals[3 * i];
        let ny = normals[3 * i + 1];
        let nz = normals[3 * i + 2];
        posArr[6 * i + 0] = x;
        posArr[6 * i + 1] = y;
        posArr[6 * i + 2] = z;
        posArr[6 * i + 3] = x + d * nx;
        posArr[6 * i + 4] = y + d * ny;
        posArr[6 * i + 5] = z + d * nz;
    }
    return {
        positions:posArr
    };
}

